// packageF/sachertorte/comm/screenPopup/screenPopup.js
const app = getApp();
Component({
  /**
   * 组件的属性列表
   */
  options: {
    styleIsolation: 'shared' //重点
  },
  properties: {
    screenShow:{
      type: Boolean,
      value: false,
    },
    cakeType:{
      type:Array,
      value:[]
    },
    getBrand: {
      type:Array,
      value:[]
    },
    priceSnacks: {
      type:Array,
      value:[]
    },
    category: {
      type:Array,
      value:[]
    },
    cakePriceArr: {
      type:Array,
      value:[]
    }
    
  },
  lifetimes: {
    // 生命周期函数，可以为函数，或一个在 methods 段中定义的方法名
    attached: function () {
      this.getiPnoneBottom();
     },
    moved: function () { },
    detached: function () { },
  },

  /**
   * 组件的初始数据
   */
  data: {
    indexType:-1,
    brandNum:5,
    brandIndex:-1, //品牌索引
    snacksIndex:-1,
    categoryIndex:-1, 
    cakeIndex:-1,
    //选择分类获取的ID系列
    brandValue: '',
    categoryValue:'',
    priceValue:['',''],
    cakeValue:'',
    cakePirceValue:['',''],
    iPnoneBottomBol:false,
    imgPath: app.globalData.imgPath,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    replacementOn() { //重置
      this.setData({
        indexType:-1,
        brandIndex:-1,
        snacksIndex:-1,
        categoryIndex:-1,
        cakeIndex:-1,
        brandValue:'',
        categoryValue:'',
        priceValue: ['',''],
        cakeValue:'',
        cakePirceValue: ['','']
      })
      this.triggerEvent('screenClick',
      {
        brandValue:'',
        categoryValue:'',
        priceValue: ['',''],
        cakeValue:'',
        cakePirceValue: ['','']
      });
    },
    exhibitionOn() {  //展开
      this.setData({
        brandNum: this.data.getBrand.length
      })
    },
    packup() { //收起
      this.setData({
        brandNum: 5
      })
    },
    onClose() {
      this.setData({ screenShow: false });
    },
    measureOn(event) { //尺寸选择
      let {index,type} = event.currentTarget.dataset;
      this.setData({
        indexType: index,
        cakeValue: type
      })
      // this.triggerEvent('measureClick', {type:type});
    },
    classifyOn(event) { //分类选择
      let {index,id} = event.currentTarget.dataset;
      this.setData({
        categoryIndex: index,
        categoryValue:id
      });
    },
    brandOn(event) { //品牌选择
      let {index,id} = event.currentTarget.dataset;
      this.setData({
        brandIndex: index,
        brandValue: id
      });
    },
    snacksOn(event) { //零食价格选择
      let {index,type} = event.currentTarget.dataset;
      this.setData({
        snacksIndex: index,
        priceValue: type,
      });
    },
    cakeClick(event) { //蛋糕价格选择
      let {index,type} = event.currentTarget.dataset;
      this.setData({
        cakeIndex: index,
        cakePirceValue: type
      });
    },
    screenOn() {  //筛选完成
      this.triggerEvent('screenClick',
      {
        brandValue:this.data.brandValue,
        categoryValue: this.data.categoryValue,
        priceValue: this.data.priceValue,
        cakeValue: this.data.cakeValue,
        cakePirceValue: this.data.cakePirceValue
      });
    },
    getiPnoneBottom() {
      try {
        var value = wx.getStorageSync("iPhoneBottom");
        if (value) {
          this.setData({
            iPnoneBottomBol: true,
          });
        }
      } catch (e) {}
    },

  }
})
